package com.qf.kele02.controller;


import com.qf.kele02.utils.Constants;
import org.apache.commons.io.IOUtils;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletResponse;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;

/**
 * @Author: 可乐
 * @Description:
 * @CreateTime: 2022-10-13  18:53
 */

@RestController
@RequestMapping("/down")
public class DownLoadController {

	@RequestMapping("/load")
	public void downLoad( String filename,HttpServletResponse response ) throws IOException {
		String filePath=Constants.RealPath+File.separator+filename;
		response.setHeader( "content-disposition","attachment;filename="+filename );
		IOUtils.copy( new FileInputStream( filePath ),response.getOutputStream( ) );
	}
}
